package com.example.demo3network;

import android.content.Context;
import android.provider.ContactsContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class RequestDataAdapter extends BaseAdapter {

    private List<LessonInfo> mLessonInfos = new ArrayList<>();
    private Context mContext;

    public RequestDataAdapter(Context context, List<LessonInfo> infos) {
        mLessonInfos = infos;
        mContext = context;
    }

    @Override
    public int getCount() {
        return mLessonInfos.size();
    }

    @Override
    public Object getItem(int i) {
        return mLessonInfos.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {

        ViewHolder viewHolder = new ViewHolder();
        if (convertView == null) {
            LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = layoutInflater.inflate(R.layout.request_data_list_view, null);
            viewHolder.mAppIconImageView = (ImageView) convertView.findViewById(R.id.requestDataListViewImage);
            viewHolder.mAppNameTextView = (TextView) convertView.findViewById(R.id.requestDataListTextView);

            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mAppNameTextView.setText(mLessonInfos.get(i).getmName());
        viewHolder.mAppIconImageView.setVisibility(View.GONE);

        return convertView;
    }


    public class ViewHolder {
        public ImageView mAppIconImageView;
        public TextView mAppNameTextView;
    }

}
